<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

    <!-- <form action="http://43.138.81.225/php/detail.php" method="get">
        <input type="text" name="id">
        <button type="submit">提交</button>
    </form> -->


    <!-- <form action="http://43.138.81.225/php/reg.php" method="post">
        <input type="text" name="username">
        <input type="text" name="password">
        <button type="submit">提交</button>
    </form> -->


    <script>

        // post 请求是通过send携带数据   --- key=value&key=value
        // 需要添加一个请求头

        const xhr = new XMLHttpRequest() ;
        xhr.open('post' , 'http://43.138.81.225/php/reg.php' , true) ;
        // 添加一个请求头   
        xhr.setRequestHeader('content-type' , 'application/x-www-form-urlencoded') ;
        xhr.send('username=yy&password=123') ;
        xhr.onreadystatechange = function() {
            if(xhr.readyState === 4 && xhr.status === 200) {
                let data = xhr.responseText ;
                console.log(data);
            }
        }

    </script>
    
</body>
</html>